<template>
  <div class="timeline">
    <div 
      v-for="(item, index) in items" 
      :key="index"
      class="timeline-item"
      :class="[`timeline-${item.type || 'default'}`]"
    >
      <div class="timeline-marker">
        <div class="marker-dot"></div>
        <div class="marker-line" v-if="index < items.length - 1"></div>
      </div>
      <div class="timeline-content">
        <div class="timeline-header">
          <h4 class="timeline-title">{{ item.title }}</h4>
          <span class="timeline-badge" v-if="item.badge">{{ item.badge }}</span>
        </div>
        <div class="timeline-description" v-if="item.description">
          {{ item.description }}
        </div>
        <div class="timeline-details" v-if="item.details">
          <ul>
            <li v-for="(detail, detailIndex) in item.details" :key="detailIndex">
              {{ detail }}
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
interface TimelineItem {
  title: string
  description?: string
  details?: string[]
  type?: 'default' | 'primary' | 'success' | 'warning' | 'info'
  badge?: string
}

interface Props {
  items: TimelineItem[]
}

defineProps<Props>()
</script>

<style scoped>
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline-item {
  position: relative;
  margin-bottom: 2rem;
  display: flex;
  gap: 1.5rem;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: relative;
  flex-shrink: 0;
}

.marker-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 3px solid white;
  box-shadow: 0 0 0 3px var(--primary-color);
  position: relative;
  z-index: 2;
}

.timeline-primary .marker-dot {
  background: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-color);
}

.timeline-success .marker-dot {
  background: var(--success-color);
  box-shadow: 0 0 0 3px var(--success-color);
}

.timeline-warning .marker-dot {
  background: var(--warning-color);
  box-shadow: 0 0 0 3px var(--warning-color);
}

.timeline-info .marker-dot {
  background: var(--info-color);
  box-shadow: 0 0 0 3px var(--info-color);
}

.marker-line {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: calc(100% + 2rem);
  background: linear-gradient(to bottom, var(--primary-color), transparent);
}

.timeline-content {
  flex: 1;
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
}

.timeline-content:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.timeline-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #111827;
}

.timeline-badge {
  background: var(--bg-gradient-primary);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timeline-description {
  color: #6b7280;
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.timeline-details ul {
  margin: 0;
  padding-left: 1.25rem;
}

.timeline-details li {
  color: #4b5563;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .timeline {
    padding-left: 1rem;
  }
  
  .timeline-item {
    gap: 1rem;
  }
  
  .timeline-content {
    padding: 1rem;
  }
  
  .timeline-title {
    font-size: 1rem;
  }
  
  .timeline-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}
</style> 